#include "mainFrame.hpp"

mainFrame::mainFrame(int width, int height) : sdlFrame(width, height)
{
    SDL_Rect rect1 = {static_cast<int>(width*0.8),
                      static_cast<int>(height*0.35),
                      85,
                      16};
    button1 = new sdlButton(this, screen, rect1, "New Game" );
    evtList.push_back(button1);

    SDL_Rect rect2 = {static_cast<int>(width*0.8),
                      static_cast<int>(height*0.40),
                      85,
                      16};
    button2 = new sdlButton(this, screen, rect2, "Hi Scores" );
    evtList.push_back(button2);

    SDL_Rect rect3 = {static_cast<int>(width*0.8),
                      static_cast<int>(height*0.45),
                      85,
                      16};
    button3 = new sdlButton(this, screen, rect3, "Exit Game" );
    evtList.push_back(button3);

    // this should be a static text.  Oh well.
    SDL_Rect rect4 = {static_cast<int>(width*0.4),
                      static_cast<int>(height*0.2),
                      110,
                      16};
    button4 = new sdlButton(this, screen, rect4, "Evil Hangman" );
    evtList.push_back(button4);

    // connect
    button1->connect(sdlEVT_COMMAND_BUTTON_CLICKED, MemberFunction&mainFrame::OnButton1Click);
    button2->connect(sdlEVT_COMMAND_BUTTON_CLICKED, MemberFunction&mainFrame::OnButton2Click);
    button3->connect(sdlEVT_COMMAND_BUTTON_CLICKED, MemberFunction&mainFrame::OnButton3Click);
    //button4 should be a static text, so it doesn't need a button click event.
}

mainFrame::~mainFrame()
{
    delete button1;
    delete button2;
    delete button3;
    delete button4;
}

// on New Game button click
void mainFrame::OnButton1Click(SDL_Event &e)
{
    fprintf(stdout, "New Game button has been clicked.\n");
}

// on Hi Scores button click
void mainFrame::OnButton2Click(SDL_Event &e)
{
    fprintf(stdout, "Hi Scores button has been clicked.\n");
}

// on Exit Game button click
void mainFrame::OnButton3Click(SDL_Event &e)
{
    //fprintf(stdout, "Exit Game button has been clicked.\n");
    close(); // closes the frame
}
